package com.itheima.utils;


import java.io.UnsupportedEncodingException;

import java.util.Random;


public class UserName {


    public static String getUsername() throws UnsupportedEncodingException {
        Random random = new Random();

        String userName = "";
        for (int i = 0; i < 3; i++) {
            userName += getUserName(random);
        }

        return userName;
    }

    private static String getUserName(Random random) throws UnsupportedEncodingException {
        Integer index = random.nextInt(127);

        String s = index.toString();


        byte[] bytes = s.getBytes();

        for (byte i = 0; i < bytes.length - 1; i++) {
            bytes[i] = (byte) -bytes[i];
        }

        String s1 = new String(bytes, "Unicode");

        return s1;
    }

}
